/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package foalvleditor.core.impl;

import foalvleditor.ctrl.BaseController;
import foalvleditor.gameobjects.AbstractGameObject;
import java.util.ArrayList;

/**
 *
 * @author Mikael
 */
public final class SelectionModel {

    private ArrayList<AbstractGameObject> selected=
    	new ArrayList<AbstractGameObject>();

    private static SelectionModel instance=new SelectionModel();

    public static SelectionModel getInstance(){
        return instance;
    }

    public void select(AbstractGameObject goa){
        this.selected.add(goa);
    }

    public void hardSelectPanel(AbstractGameObject goa){
    	BaseController.levelModel.getView().hardSelectPanel(goa);
    }

    public void deselect(AbstractGameObject goa){
        this.selected.remove(goa);
    }

    @SuppressWarnings("unchecked")
	public void deselectAll(){
        ArrayList<AbstractGameObject> removeThis=(ArrayList<AbstractGameObject>) selected.clone();
        selected.clear();
        for (int i=0; i<removeThis.size(); i++)
           {
            AbstractGameObject des=removeThis.get(i);
            BaseController.levelModel.getView().repaintPanel(des);
        }
        BaseController.levelModel.getView().repaintAll();
    }

    public boolean isSelected(AbstractGameObject goa){
        return this.selected.contains(goa);
    }
    public ArrayList<AbstractGameObject> getSelected(){
        return this.selected;
    }
 }


